package main

import (
	"net"
	"net/rpc"
)

/*
1、自定义一个函数
2、注册到rpc
3、rpc 启动

*/

type Student struct {
	name string
	age  int
}

type HelloRpcServer struct{}

func (h *HelloRpcServer) Hello(requests string, response *string) error {
	*response = "hello" + requests
	return nil
}

func (h *HelloRpcServer) ADD(res int, response *int) error {
	*response = res
	return nil
}

func main() {

	rpc.RegisterName("HelloRpcServer", &HelloRpcServer{})

	listner, err := net.Listen("tcp", ":1234")
	if err != nil {
		panic(err)
	}

	for {
		conn, err := listner.Accept()
		if err != nil {
			panic(err)

		}
		go rpc.ServeConn(conn)

	}
}
